
#include <signal.h>
#include <iostream>
void handler(int signum)
{
    std::cout << signum << std::endl;
    exit(0);
}

int main()
{
    struct sigaction s;
    s.sa_handler = handler;
    while(true)
       sigaction(SIGINT,&s,nullptr);
    return 0;
}

 